<!--
 * @Author: lee
 * @Date: 2024-01-15 09:39:24
 * @LastEditors: lee
 * @LastEditTime: 2024-01-16 18:17:02
 * @Description: file content
-->
<template>
  <div class="home-container bg-sky-600">
    <div class="max-w-screen-lg m-auto">
      <p>
        <nuxt-link class="text-yellow-200" to="/zh/test">去测试页(中文)</nuxt-link>
      </p>
      <p>
        <nuxt-link class="text-blue-50" to="/test">去测试页(英文)</nuxt-link>
      </p>
      <p>
        <nuxt-link to="/test/children/about">关于</nuxt-link>
      </p>

      <p>
        <button v-if="isLogin" type="button" @click="logOut">退出</button>
        <nuxt-link v-else to="/login">登录</nuxt-link>
      </p>
    </div>
  </div>
</template>
    
<script>
import { mapGetters } from "vuex";
export default {
  computed: {
    ...mapGetters(["token", "avatar", "name", "isLogin"])
  },
  // 与 data 钩子函数同级
  head() {
    // 直接返回所有SEO相关及页面配置,也可以动态设置
    return {
      title: this.seoData.title,
      meta: [
        { charset: "utf-8" },
        { name: "viewport", content: "width=device-width, initial-scale=1" },
        {
          hid: "description",
          name: "description",
          content: this.seoData.desc
        },
        { name: "renderer", content: "webkit" }
        // 更多标签...
      ]
      // 该页图标
      // link: [{ rel: "icon", type: "image/x-icon", href: "/favicon1.ico" }],
    };
  },
  data() {
    return {
      lang: this.$i18n.locale, //当前语言
      date: null
    };
  },
  async asyncData({ app, $testAPI }) {
    const { data } = await $testAPI.getHome({
      id: 1
    });
    // console.log('444',data);
    return { seoData: data };
  },
  methods: {
    logOut() {
      this.$store.dispatch("logOUt").then(() => {
        console.log("退出成功");
        // this.$router.push('/login')
        location.href = "/login";
      });
    }
  }
};
</script>
    
<style lang="scss" scoped>
.home-container {
  min-height: 100vh;
}
</style>
    